package com.hejr.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: hejr
 * @desc: 登录拦截器
 * @date: 2019/4/17 9:19
 */
@Slf4j
class LoginInterceptor implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("开始拦截登录请求....");
        String token = request.getParameter("token");
        if (StringUtils.isEmpty(token)) {
            response.getWriter().println("not found token");
            return false;
        }
        return true;

    }
}
